<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>标题</title>
<script src="js\jqery-3.5.1.min.js"></script>
<script src=""></script>
<meta name="keywords" content="">
<meta name="description" content="">
<style>
 *{margin:0; padding:0; list-style:none;}
 #box{
  width: 100px;
  height: 100px;
  background: #ccc;
  /* padding: 50px; */
  display: block;
 }
</style>
<link rel="stylesheet" href="./css/picture.css">
</head>
<body>

 <div id="pict">
    <div class="content" id="pic">
    </div>
    
 </div>
<script>
var n=0;
var imgs=new Array();
var box=document.getElementById('pic');
var pic=document.getElementById('pic');
box.ondragover=function (e){
 e.preventDefault();
}
box.ondrop=function (e){
 e.preventDefault();
 // console.log(e.dataTransfer.files[0]);
 var f=e.dataTransfer.files[0];//获取到第一个上传的文件对象
 var fr=new FileReader();//实例FileReader对象
 fr.readAsDataURL(f);//把上传的文件对象转换成url
 fr.onload=function (e){
//   console.log(e);
  // var Url=e.target.result;//上传文件的URL
  var Url=this.result;//上传文件的URL
  imgs[n++]=Url;
  pic.innerHTML+='<img src="'+Url+'" alt="">';
  
console.log("上传开始");  
$.ajax({
            url: "http://192.168.137.175/user/uploaduserimage",
            ret: "0",
            type:"POST",
            dataType: "json",
            data: JSON.stringify({
                img:imgs,
            }),
            success: function(data){
                console.log(data)
                // if (data.ret != "0"){
                //     window.location.href="http://192.168.137.175/login.html"
                // }  
                // else{
                //     window.location.href="http://192.168.137.175/shoppingcar.html"
                // }
            }
        })

 }
console.log("上传结束");  
 
}


</script>
</body>
</html>
